package cn.wolfcode.service.Impl;

import cn.wolfcode.domain.MessageReplyHzh;
import cn.wolfcode.mapper.MessageReplyHzhMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IMessageReplyHzhService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageReplyHzhServiceImpl implements IMessageReplyHzhService {

    @Autowired
    private MessageReplyHzhMapper messageReplyHzhMapper;


    @Override
    public void save(MessageReplyHzh messageReplyHzh) {
        messageReplyHzhMapper.insert(messageReplyHzh);
    }

    @Override
    public void delete(Long id) {
        messageReplyHzhMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(MessageReplyHzh messageReplyHzh) {
        messageReplyHzhMapper.updateByPrimaryKey(messageReplyHzh);
    }

    @Override
    public List<MessageReplyHzh> get(Long id) {
        List<MessageReplyHzh>replyHzhs = messageReplyHzhMapper.selectByPrimaryKey(id);
            return replyHzhs;
    }

    @Override
    public List<MessageReplyHzh> listAll() {
        return messageReplyHzhMapper.selectAll();
    }

    @Override
    public PageInfo<MessageReplyHzh> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<MessageReplyHzh> messageReplyHzhs = messageReplyHzhMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<MessageReplyHzh>(messageReplyHzhs);
    }
}
